package com.example.trackcircuitdiagnosis.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.trackcircuitdiagnosis.entity.DeviceInformationEntity;
import com.example.trackcircuitdiagnosis.entity.MysqlBack;
import com.example.trackcircuitdiagnosis.service.IMysqlBackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 数据库备份表 前端控制器
 * </p>
 *
 * @author ChengYuan Mao
 * @since 2022-12-26
 */
@RestController
@CrossOrigin
@RequestMapping("/mysqlBack")
public class MysqlBackController {

    @Autowired
    private IMysqlBackService mysqlBackService;

    @ResponseBody
    @GetMapping(value = "/getList")
    @Operation(
            description = "查找数据库备份信息",
            responses = {
                    @io.swagger.v3.oas.annotations.responses.ApiResponse(description = "数据库备份信息", content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = MysqlBack.class)))
            }
    )
    public Page<MysqlBack> getList(@RequestParam Integer pageNum,
                                   @RequestParam Integer pageSize) {
        QueryWrapper<MysqlBack> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("id");
        return mysqlBackService.page(new Page<>(pageNum, pageSize), queryWrapper);
    }



    @ResponseBody
    @RequestMapping(value = "/databaseBack")
    public void databaseBack() {
        mysqlBackService.databaseBack();
    }


}
